﻿using System;

namespace ExFlash.Tags
{
    public class UnknownTag : Tag
    {
        public Byte[] Data
        {
            get;
            protected set;
        }

        public String Comment
        {
            get;
            protected set;
        }

        public Exception InnerException
        {
            get;
            protected set;
        }

        public UnknownTag(ushort code, int len, Int32 offset)
            : this(code, len, offset, String.Empty, null)
        {

        }

        public UnknownTag(ushort code, int len, Int32 offset, String comment)
            : this(code, len, offset, comment, null)
        {
            
        }

        public UnknownTag(ushort code, int len, Int32 offset, String comment, Exception innerEx)
            : base(code, len, offset)
        {
            Comment = comment;
            InnerException = innerEx;
        }
        
        public override void SwfDeserialize(BinaryBitReader reader)
        {
            Data = new Byte[TagLength];
            reader.Read(Data, 0, TagLength);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        public override string ToString()
        {
            if (!Comment.Equals(String.Empty))
            {
                return base.ToString() + ", " + Comment;
            }
            else
            {
                return base.ToString();

            }
        }
    }
}
